// 封装所有和用户相关的接口函数

import httpInstance from "@/utils/http"


export const loginAPI = ({username, password}) => {
    return httpInstance({
        url: '/user/login',
        method: 'POST',
        data: {
            username,
            password
        }
    })
}

export const logoutAPI = () => {
    return httpInstance({
        url: '/user/logout',
        method: 'POST'
    })
}

export const getLikeListAPI = ({limit = 4}) => {
    return httpInstance({
        url: '/goods/relevant',
        params: {
            limit
        }
    })
}

export const addUseRoleAPI = (id, roleNames) => {
    return httpInstance({
        url: '/user/add/role',
        method: "POST",
        data: {
            id: id,
            roleNames: roleNames
        }
    })
}

export const updatePassword = (password) => {
    return httpInstance({
        url: '/user/set_password',
        method: 'POST',
        data: {password: password}
    })
}

export const registerApi = (user) => {
    return httpInstance({
        url: '/user/add',
        method: 'POST',
        data: user
    })
}